package com.globant.dashboard.model;

import java.util.List;
import javax.persistence.*;

@Entity
@Table (name="users")
public class User {

	public User() {
	}

	public User(String email, String password, boolean enabled) {
		setEmail(email);
		setPassword(password);
		setEnabled(enabled);
	}
	
	public User(String name, String email, Role accessType, boolean enabled) {
		setName(name);
		setEmail(email);
		setAccessType(accessType);
		setEnabled(enabled);
	}

	public User(String name, String company, List<Language> languages,
			String jobTitle, String experience, String password, String email,
			Role accessType, boolean enabled) {
		setName(name);
		setCompany(company);
		setExperience(experience);
		setJobTitle(jobTitle);
		setPassword(password);
		setEmail(email);
		setAccessType(accessType);
		setLanguages(languages);
		setEnabled(enabled);
	}

	/*
	 * Attributes of User
	 */

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="userId")
	private int id;

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	@Column(name = "Name", nullable = false, length = 50)
	private String name;

	@Column(name = "Company", nullable = true, length = 20)
	private String company;

	@Column(name = "JobTitle", nullable = true, length = 50)
	private String jobTitle;

	@Column(name = "Email", nullable = false, length = 30)
	private String email;
	
	@ManyToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
	private Role accessType;

	@Column(name = "Experience", nullable = true, length = 500)
	private String experience;
	
	@ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
	private List<Language> languages;

	@Column(name = "password", nullable = true, length = 20)
	private String password;
	
	@Column(name = "enabled", nullable = false, columnDefinition= "boolean default '1'")
	private boolean enabled;

	/*
	 * Getters and Setters of each attribute
	 */

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getJobTitle() {
		return jobTitle;
	}

	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Role getAccessType() {
		return accessType;
	}

	public void setAccessType(Role accessType) {
		this.accessType = accessType;
	}

	public String getExperience() {
		return experience;
	}

	public void setExperience(String experience) {
		this.experience = experience;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public List<Language> getLanguages() {
		return languages;
	}

	public void setLanguages(List<Language> languages) {
		this.languages = languages;
	}

}
